Can anyone help a newbie DXL coder with setting the access rights to an attribute value. |
Re: Changing Atttribute access rights
You are getting crashes since you must, in DXL, declare your arrays at the full size at definition time: string sGroups[i], well 'i' might not be big enough.
Lets talk about Attr Defintion rights, and presume we give access to groups, not to specific users.
o If the attr access is Specific then set it to Inherited:
AttrDef ad = find(mod, NameAttrDef)
isAccessInheritied(ad, IsInherit)
if (!IsInherit) inherited(ad)
o Set it to Specific
specific(ad)
o Provide yourself full access
setDef(mod, ad, read | modify | create | delete | control, doorsname())
o Remove all the others. Stage in a Skip, then delete
AccessRec ar
Skip skpARs = createString()
for ar in ad do
{ NameUser = username(ar)
if (NameUser == doorsname()) continue // Its me, don't delete
put(skpARs, NameUser, ar)
}
// now delete
for ar in skpARs do
{ NameUser = (string key skpARs)
unsetDef(mod, ar, NameUser)
}
delete(skpARs)
o OK. Specific Access, I have the only access rec. Now add the ones I want
For every desired access rec
{ NameUser = desired Group Name
Permission ps = desired Permission
setDef(mod, ad, ps, NameUser)
}
o Delete the AR associated with me
unsetDef(mod, ar, doorsname())
|
Re: Changing Atttribute access rights llandale - Thu May 20 16:47:50 EDT 2010
You are getting crashes since you must, in DXL, declare your arrays at the full size at definition time: string sGroups[i], well 'i' might not be big enough.
Lets talk about Attr Defintion rights, and presume we give access to groups, not to specific users.
o If the attr access is Specific then set it to Inherited:
AttrDef ad = find(mod, NameAttrDef)
isAccessInheritied(ad, IsInherit)
if (!IsInherit) inherited(ad)
o Set it to Specific
specific(ad)
o Provide yourself full access
setDef(mod, ad, read | modify | create | delete | control, doorsname())
o Remove all the others. Stage in a Skip, then delete
AccessRec ar
Skip skpARs = createString()
for ar in ad do
{ NameUser = username(ar)
if (NameUser == doorsname()) continue // Its me, don't delete
put(skpARs, NameUser, ar)
}
// now delete
for ar in skpARs do
{ NameUser = (string key skpARs)
unsetDef(mod, ar, NameUser)
}
delete(skpARs)
o OK. Specific Access, I have the only access rec. Now add the ones I want
For every desired access rec
{ NameUser = desired Group Name
Permission ps = desired Permission
setDef(mod, ad, ps, NameUser)
}
o Delete the AR associated with me
unsetDef(mod, ar, doorsname())
A few notes of the code:
o Remove all the others. Stage in a Skip, then delete
AccessRec ar
Skip skpARs = createString()
for ar in ad do
{ NameUser = username(ar)
if (NameUser == doorsname()) continue // Its me, don't delete
-> if ( null(NameUser) ) continue // Its default user (Everyone else), dont delete
put(skpARs, NameUser, ar)
}
// now delete
for ar in skpARs do
{ NameUser = (string key skpARs)
-> //unsetDef(mod, ar, NameUser) // wrong type for second argument
-> unsetDef(mod, ad, NameUser) // We are unsetting attr def 'ad' for user 'NameUser'
}
-> setDef(mod, ad, "", ?) // Set default user to something
delete(skpARs)
|
Re: Changing Atttribute access rights I did managed to get my heath robinson code to work as the problem was in trying the delete access record 0 which must be some DOORS protected record which I guess is "Everyone else" (I was setting the array size just hadn't included it in the code I originally pasted in. I'm not familiar with skip lists but it looks like something to investigate as seem easier to use than arrays. I've copied the working code below which shows that the suggestions I received would have been better! Thanks once again to those who responded. //find number of permissions set to establish required size of array int j = 0 for ar in values ad do { j++ } //create array of users with defined permissions string sVRSGroups[j] j=0 for ar in values ad do { sVRSGroups[j] = (username ar) j++ } //clear permissions for all except CEO and DOORS Administrators for (j=1; j < sizeof sVRSGroups; j++) { //necessary to start j=1 as 0 throws up an error as can not delete default everyone access if ((sVRSGroups[j] != "CEO") and (sVRSGroups[j] != "DOORS Administrators")) { ErrMess unsetVal(m, ad, sVRSGroups[j]) } } |